package com.example.springboot02_controller.controller.service.impl;


import com.example.springboot02_controller.controller.dao.UserDao;
import com.example.springboot02_controller.controller.entity.User;
import com.example.springboot02_controller.controller.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;


    @Override
    public User getById(Integer id){
        return userDao.getOne(id);
    }


    @Override
    public  User addUser(User user){
        return userDao.save(user);
    }

    @Override
    public User updateUser(User user){
        return userDao.save(user);
    }

    @Override
    public void deleteUser(int id) {
        userDao.deleteById(id);
    }
}

